home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Sound
/
World of Sound.iso
/
utils
/
miditools
/
kawaied
/
src
/
envdisplay1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-25
|
13KB
|
551 lines
#include "inc.h"
#include "defs.h"
#include "req_manx_5.c"
#include <exec/memory.h>
extern int envlevel[4];
extern int envdelay[4];
extern int envattack[4];
extern int envdecay[4];
extern int envsustain[4];
extern int envrelease[4];
extern int mute[4];
extern int sources;
int oldenvlevel[4];
int oldenvdelay[4];
int oldenvattack[4];
int oldenvdecay[4];
int oldenvsustain[4];
int oldenvrelease[4];
int delx[4],dely[4];
int attx[4],atty[4];
int decx[4],decy[4];
int relx[4],rely[4];
int x1[4],y1[4],x2[4],y2[4],x3[4],y3[4],x4[4],y4[4],x5[4],y5[4];
int X1[4],Y1[4],X2[4],Y2[4],X3[4],Y3[4],X4[4],Y4[4],X5[4],Y5[4];
struct Window *WIN;
struct RastPort *RP;
void EnvDisplay(void);
void EnvEdit(int nr);
void BigEnvDisplay(int nr);
void SaveCoord(void);
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void EnvDisplay(void)
{
int i;
int x1[4],y1[4],x2[4],y2[4],x3[4],y3[4],x4[4],y4[4],x5[4],y5[4];
BOOL f;
f=4;
for (i=0;i<=2*(sources+1)-1;i++)
{
if(oldenvlevel[i] != envlevel[i] ) f=i;
if(oldenvdelay[i] != envdelay[i] ) f=i;
if(oldenvattack[i] != envattack[i] ) f=i;
if(oldenvdecay[i] != envdecay[i] ) f=i;
if(oldenvsustain[i] != envsustain[i]) f=i;
if(oldenvrelease[i] != envrelease[i]) f=i;
}
if (f!=4)
{
for (i=2*(sources+1)-1;i>=0;i--)
{
x1[i]=260+10*(3-i); y1[i]=0;
x2[i]=x1[i]+envdelay[i]*35/100; y2[i]=0;
x3[i]=x2[i]+envattack[i]*40/100; y3[i]=envlevel[i]*35/100;
x4[i]=x3[i]+envdecay[i]*40/100; y4[i]=envsustain[i]*35/100*envlevel[i]/100;
x5[i]=x4[i]+envrelease[i]*40/100; y5[i]=0;
}
SetAPen(rp,0);
RectFill(rp,261,21,452,74);
SetAPen(rp,1);
for (i=2*(sources+1)-1;i>=0;i--)
{
int ii=74-5*i;
if (mute[i]!=0) goto Ende;
SetAPen(rp,2);
AreaMove(rp,x1[i] ,ii-y1[i]);
AreaDraw(rp,x2[i] ,ii-y2[i]);
AreaDraw(rp,x3[i] ,ii-y3[i]);
AreaDraw(rp,x4[i] ,ii-y4[i]);
AreaDraw(rp,x5[i] ,ii-y5[i]);
AreaEnd(rp);
SetAPen(rp,1);
Line(win,x1[i] ,ii-y1[i] ,x2[i] ,ii-y2[i]);
Line(win,x2[i] ,ii-y2[i] ,x3[i] ,ii-y3[i]);
Line(win,x3[i] ,ii-y3[i] ,x4[i] ,ii-y4[i]);
Line(win,x4[i] ,ii-y4[i] ,x5[i] ,ii-y5[i]);
Line(win,x1[i] ,ii-y1[i] ,x5[i] ,ii-y5[i]);
Ende: ;
}
}
Line(win,261,59,291,74);
for (i=0;i<=2*(sources+1)-1;i++)
{
oldenvlevel[i] = envlevel[i];
oldenvdelay[i] = envdelay[i];
oldenvattack[i] = envattack[i];
oldenvdecay[i] = envdecay[i];
oldenvsustain[i] = envsustain[i];
oldenvrelease[i] = envrelease[i];
}
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void EnvEdit(int nr)
{
FILE *fp,*fopen();
char string[255];
static struct NewWindow nw;
struct Gadget *gad;
int id,i,ii;
int x,y,xold,yold;
char *p=(char *)0xbfe001;
int oldenvlevel[4];
int oldenvdelay[4];
int oldenvattack[4];
int oldenvdecay[4];
int oldenvsustain[4];
int oldenvrelease[4];
for (i=0;i<=3;i++)
{
oldenvlevel[i]=envlevel[i];
oldenvdelay[i]=envdelay[i];
oldenvattack[i]=envattack[i];
oldenvdecay[i]=envdecay[i];
oldenvsustain[i]=envsustain[i];
oldenvrelease[i]=envrelease[i];
}
nw.Width = 620;
nw.Height = 110+100*sources;
nw.DetailPen = 0;
nw.BlockPen = 1;
nw.Title ="KAWAI K1-II Librarian...Graphic Envelope Editor";
nw.Flags=RMBTRAP|ACTIVATE|REPORTMOUSE|SMART_REFRESH|WINDOWDRAG|WINDOWCLOSE|(SCREEN==0 ? WINDOWDEPTH : NULL);
nw.IDCMPFlags = MOUSEBUTTONS|GADGETUP|GADGETDOWN|CLOSEWINDOW|MOUSEMOVE;
nw.Type = (SCREEN != 0 ? CUSTOMSCREEN : WBENCHSCREEN);
nw.CheckMark = NULL;
nw.NextGadget=NULL;
nw.Screen = (SCREEN != 0 ? scr : NULL);
nw.BitMap = NULL;
nw.MinWidth = 0;
nw.MinHeight = 0;
nw.MaxWidth = 0;
nw.MaxHeight = 0;
nw.LeftEdge = 10;
nw.TopEdge = 10;
WIN=(struct Window *) OpenWindow(&nw);
if (WIN==NULL) Error("Can't open EnvEdit-window");
RP=WIN->RPort;
SetFont(RP,textfont);
/* Setup window */
SetAPen(RP,1);
Print(WIN,13,103+100*sources,"Undo");
MakeDBox(WIN,10,95+100*sources,50,105+100*sources);
MakeBox(WIN,100,20,300,90); MakeBox(WIN,400,20,600,90);
if (sources==1)
{
MakeBox(WIN,100,120,300,190); MakeBox(WIN,400,120,600,190);
}
for (i=0;i<=2*(sources+1)-1+(sources==0 ? 1 : 0);i++) BigEnvDisplay(i);
Loop: WIN->IDCMPFlags = CLOSEWINDOW|MOUSEBUTTONS;
WaitPort(WIN->UserPort);
while(mesg = (struct IntuiMessage *) GetMsg(WIN->UserPort))
{
class=mesg->Class;
code=mesg->Code;
x=mesg->MouseX;
y=mesg->MouseY;
if (class==GADGETUP || class==GADGETDOWN)
{
gad=mesg->IAddress;
id=gad->GadgetID;
}
ReplyMsg((struct Message *)mesg);
WIN->IDCMPFlags= NULL;;
for (i=0;i<=3;i++)
{
X1[i]=x1[i]; Y1[i]=y1[i];
X2[i]=x2[i]; Y2[i]=y2[i];
X3[i]=x3[i]; Y3[i]=y3[i];
X4[i]=x4[i]; Y4[i]=y4[i];
X5[i]=x5[i]; Y5[i]=y5[i];
}
switch(class)
{
case CLOSEWINDOW:
{
CloseWindow(WIN);
return();
break;
}
}
if (x>=10 && x<=50 && y>=95+100*sources && y<=105+100*sources) /* Undo */
{
if (MyReq("Are you shure ?"," Yes ","Oh no"))
{
for (i=0;i<=3;i++)
{
envlevel[i] =oldenvlevel[i];
envdelay[i] =oldenvdelay[i];
envattack[i] =oldenvattack[i];
envdecay[i] =oldenvdecay[i];
envsustain[i] =oldenvsustain[i];
envrelease[i] =oldenvrelease[i];
BigEnvDisplay(i);
}
TransmitSingleSound(nr);
}
}
if (*p != -4)
{
printf("%d\n", *p);
if ((i=CheckDelay(x,y))>=0)
{
int val;
if (i==1 || i==3) x-=400;
else x-=100;
if (i==2 || i==3) y-=120;
else y-=30;
while(*p != -4)
{
SaveCoord();
xold=val;
x=WIN->MouseX;
y=WIN->MouseY;
if (i==1 || i==3) x-=400;
else x-=100;
if (i==2 || i==3) y-=140;
else y-=30;
val=2*x;
if (val>=100) val=100;
if (val<=0) val=0;
envdelay[i]=val;
if (xold != val)
{
BigEnvDisplay(i);
SingleParameterSend(42,i,envdelay[i]);
}
}
}
if ((i=CheckAttack(x,y))>=0)
{
int valx,valy;
if (i==1 || i==3) x-=400;
else x-=100;
if (i==2 || i==3) y-=130;
else y-=30;
while(*p != -4)
{
SaveCoord();
xold=valx;
yold=valy;
x=WIN->MouseX;
y=WIN->MouseY;
if (i==1 || i==3) x-=400;
else x-=100;
x=x-envdelay[i]/2;
if (i==2 || i==3) y-=130;
else y-=30;
valx=x*2;
valy=100-y*100/60;
if (valx>=100) valx=100;
if (valx<=0) valx=0;
if (valy>=100) valy=100;
if (valy<=0) valy=0;
envattack[i]=valx;
envlevel[i]=valy;
if (xold != valx || yold !=valy)
{
BigEnvDisplay(i);
SingleParameterSend(43,i,envattack[i]);
SingleParameterSend(41,i,envlevel[i]);
}
}
}
if ((i=CheckDecay(x,y))>=0)
{
int valx,valy;
if (i==1 || i==3) x-=400;
else x-=100;
if (i==2 || i==3) y-=130;
else y-=30;
while(*p != -4)
{
SaveCoord();
xold=valx;
yold=valy;
x=WIN->MouseX;
y=WIN->MouseY;
if (i==1 || i==3) x-=400;
else x-=100;
x=x-envdelay[i]/2-envattack[i]/2;
if (i==2 || i==3) y-=130;
else y-=30;
valx=x*2;
valy=(envlevel[i] != 0 ? (100-y*100/60)*100/envlevel[i] : 0);
if (valx>=100) valx=100;
if (valx<=0) valx=0;
if (valy>=100) valy=100;
if (valy<=0) valy=0;
envdecay[i]=valx;
envsustain[i]=valy;
if (xold != valx || yold !=valy)
{
BigEnvDisplay(i);
SingleParameterSend(44,i,envdecay[i]);
SingleParameterSend(45,i,envsustain[i]);
}
}
}
if ((i=CheckRelease(x,y))>=0)
{
int valx,valy;
if (i==1 || i==3) x-=400;
else x-=100;
if (i==2 || i==3) y-=130;
else y-=30;
while(*p != -4)
{
SaveCoord();
xold=valx;
yold=valy;
x=WIN->MouseX;
y=WIN->MouseY;
if (i==1 || i==3) x-=400;
else x-=100;
x=x-envdelay[i]/2-envattack[i]/2-envdecay[i]/2;
if (i==2 || i==3) y-=130;
else y-=30;
valx=x*2;
if (valx>=100) valx=100;
if (valx<=0) valx=0;
envrelease[i]=valx;
if (xold != valx || yold !=valy)
{
BigEnvDisplay(i);
SingleParameterSend(46,i,envrelease[i]);
}
}
}
}
}
goto Loop;
Loop1: CloseWindow(WIN);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
int CheckDelay(int x, int y)
{
int i;
for (i=0;i<=3;i++)
{
if (x<=delx[i]+0 && x>=delx[i]-7 && y<dely[i]+3 && y>dely[i]-3) return(i);
}
return(-1);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
int CheckAttack(int x, int y)
{
int i;
for (i=0;i<=3;i++)
{
if (x<=attx[i]+2 && x>=attx[i]-5 && y<atty[i]+3 && y>atty[i]-3) return(i);
}
return(-1);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
int CheckDecay(int x, int y)
{
int i;
for (i=0;i<=3;i++)
{
if (x<=decx[i]+5 && x>=decx[i]-1 && y<decy[i]+3 && y>decy[i]-3) return(i);
}
return(-1);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
int CheckRelease(int x, int y)
{
int i;
for (i=0;i<=3;i++)
{
if (x<=relx[i]+7 && x>=relx[i]-0 && y<rely[i]+3 && y>rely[i]-3) return(i);
}
return(-1);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void BigEnvDisplay(int i)
{
char string[255];
int ii;
SetAPen(RP,0);
SetBPen(RP,0);
Line(WIN,X1[i] ,Y1[i] ,X2[i] ,Y2[i]);
Line(WIN,X2[i] ,Y2[i] ,X3[i] ,Y3[i]);
Line(WIN,X3[i] ,Y3[i] ,X4[i] ,Y4[i]);
Line(WIN,X4[i] ,Y4[i] ,X5[i] ,Y5[i]);
MakeBox(WIN,X2[i]-7,Y2[i]-3,X2[i]+0,Y2[i]+3);
MakeBox(WIN,X3[i]-5,Y3[i]-3,X3[i]+2,Y3[i]+3);
MakeBox(WIN,X4[i]-1,Y4[i]-3,X4[i]+5,Y4[i]+3);
MakeBox(WIN,X5[i]-0,Y5[i]-3,X5[i]+7,Y5[i]+3);
SetAPen(RP,1);
SetAPen(RP,1);
if (i==0) MakeBox(WIN,100,20,300,90);
if (i==1) MakeBox(WIN,400,20,600,90);
if (i==2) MakeBox(WIN,100,120,300,190);
if (i==3) MakeBox(WIN,400,120,600,190);
ii=90+100*(i/2);
x1[i]=300*(i%2)+100; y1[i]=ii;
x2[i]=x1[i]+envdelay[i]*50/100; y2[i]=ii;
x3[i]=x2[i]+envattack[i]*50/100; y3[i]=ii-envlevel[i]*60/100;
x4[i]=x3[i]+envdecay[i]*50/100; y4[i]=ii-envsustain[i]*60/100*envlevel[i]/100;
x5[i]=x4[i]+envrelease[i]*50/100; y5[i]=ii;
delx[i]=x2[i]; dely[i]=y2[i];
attx[i]=x3[i]; atty[i]=y3[i];
decx[i]=x4[i]; decy[i]=y4[i];
relx[i]=x5[i]; rely[i]=y5[i];
Line(WIN,x1[i] ,y1[i] ,x2[i] ,y2[i]);
Line(WIN,x2[i] ,y2[i] ,x3[i] ,y3[i]);
Line(WIN,x3[i] ,y3[i] ,x4[i] ,y4[i]);
Line(WIN,x4[i] ,y4[i] ,x5[i] ,y5[i]);
SetAPen(RP,2);
MakeBox(WIN,x2[i]-7,y2[i]-3,x2[i]+0,y2[i]+3);
MakeBox(WIN,x3[i]-5,y3[i]-3,x3[i]+2,y3[i]+3);
MakeBox(WIN,x4[i]-1,y4[i]-3,x4[i]+5,y4[i]+3);
MakeBox(WIN,x5[i]-0,y5[i]-3,x5[i]+7,y5[i]+3);
sprintf(string,"Env #%d",i+1);
Print(WIN,175+300*(i%2),18+100*(i/2),string);
sprintf(string,"Del: %3d",envdelay[i]);
ColPrint(WIN,10+300*(i%2),30+100*(i/2)-2,string);
sprintf(string,"Att: %3d",envattack[i]);
ColPrint(WIN,10+300*(i%2),40+100*(i/2)-2,string);
sprintf(string,"Dec: %3d",envdecay[i]);
ColPrint(WIN,10+300*(i%2),50+100*(i/2)-2,string);
sprintf(string,"Sus: %3d",envsustain[i]);
ColPrint(WIN,10+300*(i%2),60+100*(i/2)-2,string);
sprintf(string,"Rel: %3d",envrelease[i]);
ColPrint(WIN,10+300*(i%2),70+100*(i/2)-2,string);
sprintf(string,"Lev: %3d",envlevel[i]);
ColPrint(WIN,10+300*(i%2),80+100*(i/2)-2,string);
if (mute[i]==1) ColPrint(WIN,10+300*(i%2),90+100*(i/2)-2,"OFF");
SetAPen(RP,1);
}
/**********************************************************************************/
/*** ***/
/**********************************************************************************/
void SaveCoord(void)
{
int i;
for (i=0;i<=3;i++)
{
X1[i]=x1[i]; Y1[i]=y1[i];
X2[i]=x2[i]; Y2[i]=y2[i];
X3[i]=x3[i]; Y3[i]=y3[i];
X4[i]=x4[i]; Y4[i]=y4[i];
X5[i]=x5[i]; Y5[i]=y5[i];
}
}